<template>
  <div class="contanier">
    <div class="top">
      <el-row :gutter="10">
        <el-col :span="24">
          <div class="num">
            <el-card body-style="display: flex;padding: 0px;">
              <i
                class="el-icon-user-solid icon"
                style="background: skyblue"
              ></i>
              <div class="detail">
                <p class="number">
                  {{ all.length }}
                </p>
                <p class="dec">用户总数</p>
              </div>
            </el-card>
            <el-card body-style="display: flex;padding: 0px;">
              <i class="el-icon-user-solid icon" style="background: pink"></i>  

              <div class="detail">
                <p class="number">
                  {{ hotdata.length }}
                </p>

                <p class="dec">热门景区个数</p>
              </div>
            </el-card>
            <el-card body-style="display: flex;padding: 0px;">
              <i class="el-icon-star-off icon" style="background: #67c23a"></i>

              <div class="detail">
                <p class="number">
                  {{ strategydata.length }}
                </p>
                <p class="dec">旅游攻略篇数</p>
              </div>
            </el-card>
            <el-card body-style="display: flex;padding: 0px;">
              <i class="el-icon-reading icon" style="background: #e6a23c"></i>  

              <div class="detail">
                <p class="number">
                  {{ newdata.length }}
                </p>

                <p class="dec">旅游快讯篇数</p>
              </div>
            </el-card>
          </div>
        </el-col>
      </el-row>
      
    </div>
    <!-- <Amap style="margin: 10px"></Amap> -->
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { getall } from "@/api/user.js";
import { gethotdata } from "@/api/hot";
import { getnewdata } from "@/api/new";
import { getstrategydata } from "@/api/strategy";
import Amap from "@/components/Amap/index.vue";
export default {
  name: "Dashboard",
  computed: {
    ...mapGetters(["name", "strategydata", "hotdata", "newdata", "all"]),
  },
  components: {
    Amap,
  },
  mounted() {
    this.initdata1();
    this.initdata2();
    this.initdata3();
    this.initdata4();
  },
  methods: {
    async initdata1() {
      let result = await getall();
      console.log(result);
      if (result.status == 0) {
        this.$store.dispatch("user/getall", result.data);
      }
    },
    async initdata2() {
      let result = await gethotdata();
      if (result.status == 0) {
        this.$store.dispatch("hot/savedata", result.data);
      }
    },
    async initdata3() {
      let result = await getnewdata();
      if (result.status == 0) {
        this.$store.dispatch("news/savedata", result.data);
      }
    },
    async initdata4() {
      let result = await getstrategydata();
      if (result.status == 0) {
        this.$store.dispatch("strategy/savedata", result.data);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
.user {
  display: flex;
  align-items: center;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid #ccc;
  img {
    margin-right: 40px;
    height: 120px;
    width: 120px;
    border-radius: 50%;
  }
  .userinfo {
    .name {
      font-size: 25px;
      margin-bottom: 10px;
    }
    .access {
      color: #999;
      margin: 0px;
      padding: 0px;
    }
  }
}
.task {
  p {
    font-family: KaiTi, serif;
    font-weight: 500;
    color: black;
  }
}
.num {
  display: flex;
  justify-content: space-between;
  flex-wrap: nowrap;
  margin-left: 5px;
  .icon {
    width: 80px;
    height: 80px;
    font-size: 30px;
    text-align: center;
    line-height: 80px;
    color: #fff;
  }
  .detail {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-left: 15px;

    .number {
      font-size: 30px;
      margin: 0px;
      margin-bottom: 10px;
      line-height: 30px;
      height: 30px;
    }
    .dec {
      font-size: 14px;
      color: #999;
      text-align: center;
      margin: 0px;
    }
  }
  .el-card {
    width: 25%;
    margin-right: 10px;
  }
}
.charts {
  width: 100%;
  height: 100%;
}
.chart2 {
  width: 100%;
  height: 100%;
}
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}

.contanier{
  .top{
    margin-top: 50px;
  }
}
</style>
